package com.bjdd.jdy.entity;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/13.
 */

public class ExamBean {

    /**
     * questionId : 7
     * title : 测试6
     * enable : true
     * multi : true
     * questionCategory : {"questionCategoryId":22,"name":"测试分类"}
     * answers : [{"questionAnswerId":132,"answerOption":null,"content":"测试","result":true},{"questionAnswerId":133,"answerOption":null,"content":"42314312","result":true},{"questionAnswerId":134,"answerOption":null,"content":"321","result":false}]
     */

    private int questionId;
    private String title;
    private boolean enable;
    private boolean multi;
    private QuestionCategoryBean questionCategory;
    private List<AnswersBean> answers;

    public static ExamBean objectFromData(String str) {

        return new Gson().fromJson(str, ExamBean.class);
    }

    public static List<ExamBean> arrayExamBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<ExamBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public int getQuestionId() {
        return questionId;
    }

    public void setQuestionId(int questionId) {
        this.questionId = questionId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public boolean isMulti() {
        return multi;
    }

    public void setMulti(boolean multi) {
        this.multi = multi;
    }

    public QuestionCategoryBean getQuestionCategory() {
        return questionCategory;
    }

    public void setQuestionCategory(QuestionCategoryBean questionCategory) {
        this.questionCategory = questionCategory;
    }

    public List<AnswersBean> getAnswers() {
        return answers;
    }

    public void setAnswers(List<AnswersBean> answers) {
        this.answers = answers;
    }

    public static class QuestionCategoryBean {
        /**
         * questionCategoryId : 22
         * name : 测试分类
         */

        private int questionCategoryId;
        private String name;

        public static QuestionCategoryBean objectFromData(String str) {

            return new Gson().fromJson(str, QuestionCategoryBean.class);
        }

        public static List<QuestionCategoryBean> arrayQuestionCategoryBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<QuestionCategoryBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public int getQuestionCategoryId() {
            return questionCategoryId;
        }

        public void setQuestionCategoryId(int questionCategoryId) {
            this.questionCategoryId = questionCategoryId;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

    public static class AnswersBean {
        /**
         * questionAnswerId : 132
         * answerOption : null
         * content : 测试
         * result : true
         */

        private int questionAnswerId;
        private Object answerOption;
        private String content;
        private boolean result;
        private boolean isChexked;

        public static AnswersBean objectFromData(String str) {

            return new Gson().fromJson(str, AnswersBean.class);
        }

        public static List<AnswersBean> arrayAnswersBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<AnswersBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public int getQuestionAnswerId() {
            return questionAnswerId;
        }

        public void setQuestionAnswerId(int questionAnswerId) {
            this.questionAnswerId = questionAnswerId;
        }

        public Object getAnswerOption() {
            return answerOption;
        }

        public void setAnswerOption(Object answerOption) {
            this.answerOption = answerOption;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public boolean isResult() {
            return result;
        }

        public void setResult(boolean result) {
            this.result = result;
        }

        public boolean isChexked() {
            return isChexked;
        }

        public void setChexked(boolean chexked) {
            isChexked = chexked;
        }
    }
}
